package org.example.trader.http.api;

import lombok.extern.slf4j.Slf4j;
import org.example.common.data.Rsp;
import org.example.trader.api.TraderAPI;
import org.example.trader.data.form.TraderLoginForm;
import org.example.trader.data.view.TraderInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/trader")
public class TraderController {

    @Autowired
    private TraderAPI traderAPI;

    @RequestMapping("/login")
    public Rsp login(
            @RequestBody @Validated TraderLoginForm loginForm){

        TraderInfo traderInfo = traderAPI.loginTrader(loginForm.getAccount(), loginForm.getPassword());

        return Rsp.data(String.valueOf(System.currentTimeMillis()));

    }

    @RequestMapping("/user/info")
    public Rsp userInfo(TraderLoginForm loginForm){

//        TraderInfo traderInfo = traderAPI.loginTrader(loginForm.getAccount(), loginForm.getPassword());

        return Rsp.data("traderInfo");

    }

    @RequestMapping("/logout")
    public Rsp logout(TraderLoginForm loginForm){

//        TraderInfo traderInfo = traderAPI.loginTrader(loginForm.getAccount(), loginForm.getPassword());

        return Rsp.ok("");

    }

}
